//=============================================================================
// Claw tripmine
//=============================================================================
class ClawFiremine extends TFClaw config(user) cacheexempt;

//=============================================================================
// GiveTo
//	Gives this weapon to a player. Also adds extra ammo types.
// Modifed so that it only gives the Parent weapon (with none of the parent ammo)
// The adds the proper ammo to this class
//=============================================================================
function GiveTo(Pawn Other, optional Pickup Pickup)
{
	local ChaosWeapon W;
	local bool bPossiblySwitch;
	local byte MyCount;
	local Ammunition A;
	local WeaponPickup WP;
    local Inventory Inv;

	Instigator = Other;

    // check to see if they have the xbox
    W = ChaosWeapon(Instigator.FindInventoryType(class'TFClaw'));
	// if not give them one, but remove the normal ammo
    if ( W == None )
    {
  		Inv = Spawn(class'TFClaw');
		if( Inv != None )
		{
			Inv.GiveTo(Instigator);
			if ( Inv != None )
				Inv.PickupFunction(Instigator);
		}
        // Remove the ammo here from the standard xbow we just spawned
        A = Ammunition(Instigator.FindInventoryType(class'ClawFiremineAmmo'));
        if ( A != None)
          A.AmmoAmount=0;
    }
    // If they already have a xbow (or we just spawned one) now give them the \
    // ammo of this class
   	if ( ChaosWeaponPickup(Pickup) != None )
		MyCount = ChaosWeaponPickup(Pickup).MyCount;
	else
		MyCount = self.Count;

	WP = WeaponPickup(Pickup);
	A = Ammunition(Instigator.FindInventoryType(AmmoType[MyCount].AmmoClass));
	if ( A == None || A.class != AmmoType[MyCount].AmmoClass && WP == None)
    {
        A = Spawn(AmmoType[MyCount].AmmoClass, Instigator);
		Instigator.AddInventory(A);
	}
	// We should either give ammo that was found in the gun if it was dropped
    if ( WP != None && WP.AmmoAmount[0] > 0 )
        A.AddAmmo(WP.AmmoAmount[0]);
	else
        A.AddAmmo(A.InitialAmount);
	A.GotoState('');
	// If we had to spawn a xbow, then they dont have any other ammo yet, so switch
	// to this ammo type
    if (INV != None)
    {
        ChaosWeapon(INV).OldCount=Count;
        ChaosWeapon(INV).SwitchFireMode(count);
    }
	if ( Instigator.Weapon != W )
		W.ClientWeaponSet(bPossiblySwitch);
	// Ok we have compelted our work..its Miller time!
    Destroy();
}

defaultproperties
{
     Count=1
     ItemName="Claw 2: Fire Mines"
}
